#!/usr/bin/env python
# coding=utf-8


siteBaseUrl = r'http://www.spbo.com/'
yingChao = r'data/live.plex?fl=yingchao&p=1'


class UrlManager:
	"""
	Manage the urls of each league
	"""
	def __init__(self):
		self._baseUrl = siteBaseUrl
		self._urlsNum = {}
		self._urlTailPattern = r'data/live.plex?fl=%(league)s&p=%(pagenum)d'
		self._urlPattern = self._baseUrl + self._urlTailPattern

	def set_url_num(self, league, num):
		"""
		Set the page number of a league
		@param league: league English name
		type: string
		@param num: page number of the league
		type: int
		"""
		self._urlsNum[league] = num

	def _get_url(self, league, pagenum):
		urlTail = self._urlPattern % {'league': league, 'pagenum': pagenum}

	def get_urls(self, league):
		"""
		Get the urls of a league.
		@param league: league English name
		type: string
		@return the urls of the league
		type: tuple of strings
		@exception raise KeyError if the instance does not contain the league
		"""
		pass	# TODO

	def get_leagues(self):
		"""
		Get the leagues contained in instance
		@return English names of leagues
		type: tuple of strings
		"""
		return self_urlsNum.keys()

	def add_url(self, url):
		"""
		Adjust the page number by the given url
		@param url: url of the score
		type: string
		@return if add url and parse successfully
		@retval True: OK
		@retval False: Failed
		"""
		pass 	# TODO
	


class UrlContentFetcher:
	"""
	Fetch url content with multithread and cache.
	"""
	def __init__(self):
		pass


